home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / texdraw / compact / txdtools.tex < prev   
Text File  |  1992-07-06  |  2KB  |  81 lines

  1. % TeXdraw toolbox macros, useful for extended TeXdraw commands
  2.  
  3. % $Id: txdtools.tex,v 1.7 1992/07/07 14:42:13 kabal Rel $
  4.  
  5. %   Copyright (C) 1991,1992  Peter Kabal
  6.  
  7. % The routines in this file are provided free of charge without
  8. % warranty of any kind.  Note that the TeXdraw routines are copyrighted.
  9. % They may be distributed freely provided that the recipients also
  10. % acquire the right to distribute them freely.  The notices to this
  11. % effect must be preserved when the files are distributed.
  12.  
  13. %  Peter Kabal
  14. %  Department of Electrical Engineering
  15. %  McGill University
  16. %  3480 University
  17. %  Montreal, Quebec
  18. %  Canada  H3A 2A7
  19.  
  20. %  kabal@aldebaran.EE.McGill.CA
  21. \chardef\catamp=\the\catcode`\@
  22. \catcode`\@=11
  23. \def\realadd #1#2#3{\dimen0=#1pt
  24. \dimen2=#2pt
  25. \advance \dimen0 by \dimen2
  26. \edef #3{\expandafter\c@lean\the\dimen0}}
  27. \def\realdiv #1#2#3{\dimen0=#1pt
  28. \t@counta=\dimen0
  29. \dimen0=#2pt
  30. \t@countb=\dimen0
  31. \intdiv \t@counta \t@countb #3}
  32. \def\lenhyp #1#2#3{\t@counta=#1%
  33. \multiply \t@counta by \t@counta
  34. \t@countb=#2%
  35. \multiply \t@countb by \t@countb
  36. \advance \t@counta by \t@countb
  37. \sqrtnum \t@counta #3}
  38. \let\bk=\t@counta
  39. \let\bn=\t@countb
  40. \let\xval=\t@countc
  41. \def\sqrtnum #1#2{\xval=#1%
  42. \bk=\xval
  43. \loop
  44. \bn=\xval
  45. \divide \bn by \bk
  46. \advance \bn by \bk
  47. \advance \bn by 1
  48. \divide \bn by 2
  49. \ifnum \bn < \bk
  50. \bk=\bn
  51. \repeat
  52. #2=\bn}
  53. \def\currentpos #1#2{\t@pixa=\x@pix
  54. \advance \t@pixa by -\x@segoffpix
  55. \pixtocoord \t@pixa #1
  56. \t@pixa=\y@pix
  57. \advance \t@pixa by -\y@segoffpix
  58. \pixtocoord \t@pixa #2}
  59. \def\vectlen (#1 #2)(#3 #4)#5{\getpos (#1 #2)\x@arga\y@arga
  60. \getpos (#3 #4)\x@argb\y@argb
  61. \coordtopix \x@arga \t@pixa
  62. \coordtopix \x@argb \t@pixb
  63. \advance \t@pixb by -\t@pixa
  64. \coordtopix \y@arga \t@pixc
  65. \coordtopix \y@argb \t@pixd
  66. \advance \t@pixd by -\t@pixc
  67. \lenhyp \t@pixb \t@pixd \t@pixc
  68. \pixtocoord \t@pixc #5}
  69. \def\cossin (#1 #2)(#3 #4)#5#6{\getpos (#1 #2)\x@arga\y@arga
  70. \getpos (#3 #4)\x@argb\y@argb
  71. \coordtopix \x@arga \t@pixa
  72. \coordtopix \x@argb \t@pixb
  73. \advance \t@pixb by -\t@pixa
  74. \coordtopix \y@arga \t@pixc
  75. \coordtopix \y@argb \t@pixd
  76. \advance \t@pixd by -\t@pixc
  77. \lenhyp \t@pixb \t@pixd \t@pixc
  78. \intdiv \t@pixb\t@pixc #5%
  79. \intdiv \t@pixd\t@pixc #6}
  80. \catcode`\@=\catamp
  81.